package com.jiangnan.repository

import com.jiangnan.api.client.BookApiClient
import com.jiangnan.entity.Book
import com.jiangnan.entity.PageResult
import com.jiangnan.entity.Res
import com.jiangnan.entity.UserBorrowBookInfo
import retrofit2.http.Query

class AdminRepository {

    /**
     * 删除书籍
     */
    suspend fun deleteBookById(id: Int): Res<Any> {
        return BookApiClient.apiCall {
            BookApiClient.adminApiService.deleteBookById(id)
        }
    }
    /**
     * 修改图书信息
     */
    suspend fun updateBook(book: Book): Res<Any> {
        return BookApiClient.apiCall {
            BookApiClient.adminApiService.updateBook(book)
        }
    }

    /**
     * 查询所有用户的图书借阅情况
     */
    suspend fun getUserInfoList(page: Int, pageSize: Int,requestParam: String): Res<PageResult<UserBorrowBookInfo>>{
        return BookApiClient.apiCall {
            BookApiClient.adminApiService.getUserInfoList(page, pageSize, requestParam)
        }
    }

    /**
     * 修改用户状态
     */
    suspend fun updateUserStatus(id: Int, status: Int): Res<Any> {
        return BookApiClient.apiCall {
            BookApiClient.adminApiService.updateUserStatus(id, status)
        }
    }

}